import { ApiUser } from '@/axios/api';
import { Result } from '@/model/common';
import { UserDetailDTO } from '@/model/user';
import { Store } from '@/store';

export default class UserUtil {
    public static current(): Promise<UserDetailDTO> {
        return new Promise((resolve, reject) => {
            ApiUser.current()
                .then((res: Result) => {
                    Store.commit('user', res.data);
                    resolve(res.data);
                })
                .catch((err: Result) => {
                    reject(err);
                });
        });
    }
}
